﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Lung_Sounds_V2
{
    /// <summary>
    /// Interaction logic for RenameWindow.xaml
    /// </summary>
    public partial class RenameWindow : Window, INotifyPropertyChanged
    {
        public string Name { get; set; }

        public Visibility StartsWithInVisibility { get; set; }

        private bool _startsWithIn;
        public bool StartsWithIn 
        {
            get
            {
                return _startsWithIn;
            }

            set
            {
                if (_startsWithIn != value)
                {
                    _startsWithIn = value;
                    RaisePropertyChanged("StartsWithIn");
                }
            }
        }

        public RenameWindow(bool showStartsWithIn = false)
        {
            if (showStartsWithIn)
            {
                StartsWithInVisibility = Visibility.Visible;
            }
            else
            {
                StartsWithInVisibility = Visibility.Collapsed;
            }

            StartsWithIn = true;
            
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.Name = txtName.Text;
            this.DialogResult = true;
            this.Close();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            txtName.Text = this.Name;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
